﻿package core.image.psd
{
    import flash.utils.*;

    public class ByteArrayReader extends Object
    {
        public var Position:Number = 0;
        public var Data:ByteArray;

        public function ByteArrayReader(param1:ByteArray)
        {
            this.Data = param1;
            return;
        }// end function

        public function ReadUInt16() : uint
        {
            var _loc_1:uint = 0;
            var _loc_3:String = this;
            _loc_3.Position = this.Position + 1;
            _loc_1 = (_loc_1 << 8) + this.Data[this.Position++];
            var _loc_2:* = _loc_1 << 8;
            var _loc_3:String = this;
            _loc_3.Position = this.Position + 1;
            _loc_1 = _loc_2 + this.Data[this.Position++];
            return _loc_1;
        }// end function

        public function ReadUInt32() : uint
        {
            var _loc_1:uint = 0;
            var _loc_5:String = this;
            _loc_5.Position = this.Position + 1;
            _loc_1 = (_loc_1 << 8) + this.Data[this.Position++];
            var _loc_2:* = _loc_1 << 8;
            var _loc_5:String = this;
            _loc_5.Position = this.Position + 1;
            _loc_1 = _loc_2 + this.Data[this.Position++];
            var _loc_3:* = _loc_1 << 8;
            var _loc_5:String = this;
            _loc_5.Position = this.Position + 1;
            _loc_1 = _loc_3 + this.Data[this.Position++];
            var _loc_4:* = _loc_1 << 8;
            var _loc_5:String = this;
            _loc_5.Position = this.Position + 1;
            _loc_1 = _loc_4 + this.Data[this.Position++];
            return _loc_1;
        }// end function

        public function ReadInt32() : int
        {
            var _loc_1:int = 0;
            this.Data.position = this.Position;
            _loc_1 = this.Data.readInt();
            this.Position = this.Position + 4;
            return _loc_1;
        }// end function

        public function ReadInt16() : int
        {
            var _loc_1:int = 0;
            this.Data.position = this.Position;
            _loc_1 = this.Data.readShort();
            this.Position = this.Position + 2;
            return _loc_1;
        }// end function

        public function ReadString(ByteArrayReader.as$428:int) : String
        {
            return this.Read(ByteArrayReader.as$428).toString();
        }// end function

        public function Read(param1:int) : ByteArray
        {
            if (param1 === 0)
            {
                return new ByteArray();
            }
            var _loc_2:* = new ByteArray();
            if (this.Data.length > this.Position + param1)
            {
                this.Data.position = this.Position;
                this.Data.readBytes(_loc_2, 0, param1);
                this.Position = this.Data.position;
            }
            return _loc_2;
        }// end function

        public function ReadByte() : int
        {
            var _loc_2:String = this;
            _loc_2.Position = this.Position + 1;
            var _loc_1:* = this.Data[this.Position++];
            if ("number" === "undefined")
            {
                return 0;
            }
            return _loc_1;
        }// end function

        public function ReadChar() : String
        {
            return String.fromCharCode(this.ReadByte());
        }// end function

        public function ReadChars(ByteArrayReader.as$428:int) : String
        {
            var _loc_3:int = 0;
            var _loc_2:Array = [];
            while (_loc_3 < ByteArrayReader.as$428)
            {
                
                _loc_2[_loc_2.length] = String.fromCharCode(this.ReadByte());
                _loc_3++;
            }
            return _loc_2.join("");
        }// end function

        public function ReadPascalString() : String
        {
            var _loc_1:* = this.ReadByte();
            var _loc_2:* = this.ReadChars(_loc_1);
            if (_loc_1 % 2 == 0)
            {
                this.ReadByte();
            }
            return _loc_2;
        }// end function

    }
}
